package edu.byu.intex2.javamail;

import java.util.StringTokenizer;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.swing.JOptionPane;

/**
 * Provides credentials to authenticate with an SMTP server.  
 * @author Brady White
 */
public class SMTPAuthenticator extends Authenticator {

    public SMTPAuthenticator() {
    }

    /**
     * @return credentials to authenticate with SMTP server
     */
    @Override
    public PasswordAuthentication getPasswordAuthentication() {
//        String username, password;
//
//        // Shows a JOptionPane to prompt the user for credentials.
//        String result = JOptionPane.showInputDialog(
//                "Enter 'username,password' (i.e. billy@gmail.com,mypassword");
//
//        StringTokenizer st = new StringTokenizer(result, ",");
//        username = st.nextToken();
//        password = st.nextToken();
//
//        return new PasswordAuthentication(username, password);

        // or... just return a PasswordAuthentication with your username and password hardcoded in
        return new PasswordAuthentication("satara@gmail.com", "zippy2323");
    }
}
